/**
  ******************************************************************************
  * @file    xxx.c 
  * @author  SD Electronics xxx
  * @version V1.0
  * @date    xx-xx-xx
  * @brief   xxxxxxxxxxxxxxxxxx.
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "sd_common.h"


/** 
  * @brief  Template 硬件配置相关结构体 
  */ 
ST_Template_PHY g_stTemplatePhyParam;


/** 
  * @brief Template 控制结构体 
  */ 
ST_Template_CTRL g_stTemplateCtrl = 
{                       
    false,
    &g_stTemplatePhyParam,
};  

/**
  * @}
  */


/**
  * @brief  SDInitTemplate
  * @note   xxx
  * @param  None
  * @retval None
  */
void SDInitTemplate(PST_Template_PHY pstTemplateCntPhy)
{
    printf("usr: sd Template init.\r\n");
}

/**
  * @brief  TemplateOpen
  * @note   xxx
  * @param  None
  * @retval None
  */
static long TemplateOpen(void *pvHandle, unsigned long ulOption)
{
    PST_DEV_MANAGE pstDevManage = pvHandle;

    long lRet = EN_DEV_CTL_RET_CODE_FAILED;
    if (0 != pstDevManage)
    {
        PST_Template_CTRL pstTemplateCtrl = (PST_Template_CTRL)pstDevManage->pvData;
        if(false == pstTemplateCtrl->bInitFlag)
        {
			/* Template????? */
            SDInitTemplate(pstTemplateCtrl->pstTemplateInfo);
            pstTemplateCtrl->bInitFlag = true;
        }
        lRet = EN_DEV_CTL_RET_CODE_SUCCESSED;
    }
    return lRet;
}  

/**
  * @brief  TemplateRead
  * @note   xxx
  * @param  None
  * @retval None
  */
static long TemplateRead(void *pvHandle, unsigned long ulOpertion, unsigned char *pucDataBuf, int* ulDataSize)
{
    PST_DEV_MANAGE pstDevManage = pvHandle;
    long lRet = EN_DEV_CTL_RET_CODE_FAILED;
    if (0 != pstDevManage)
    {
        PST_Template_CTRL pstTemplateCtrl = (PST_Template_CTRL)pstDevManage->pvData;
        //
        if(true == pstTemplateCtrl->bInitFlag)
        {
            ;
        }
        lRet = EN_DEV_CTL_RET_CODE_SUCCESSED;
    }
    return lRet;    
}

/**
  * @brief  TemplateWrite
  * @note   xxx
  * @param  None
  * @retval None
  */
static long TemplateWrite(void *pvHandle, unsigned long ulOpertion, unsigned char *pucDataBuf, unsigned long ulDataLen)
{
    PST_DEV_MANAGE pstDevManage = pvHandle;
    long lRet = EN_DEV_CTL_RET_CODE_FAILED;
    if (0 != pstDevManage)
    {
        PST_Template_CTRL pstTemplateCtrl = (PST_Template_CTRL)pstDevManage->pvData;
        //
        if(true == pstTemplateCtrl->bInitFlag)
        {
           ;
        }
        lRet = EN_DEV_CTL_RET_CODE_SUCCESSED;
    }
    return lRet;
}

/**
  * @brief  TemplateControl
  * @note   xxx
  * @param  None
  * @retval None
  */
static long TemplateControl (void *pvHandle,unsigned long ulOpertion, unsigned long ulControlCmd, void *pvd)
{
    PST_DEV_MANAGE pstDevManage = pvHandle;
    long lRet = EN_DEV_CTL_RET_CODE_FAILED;
    if (0 != pstDevManage)
    { 
        PST_Template_CTRL pstTemplateCtrl = (PST_Template_CTRL)pstDevManage->pvData;
        /* ??????? */
        if(true == pstTemplateCtrl->bInitFlag)
        {
          ;
        }
        lRet = EN_DEV_CTL_RET_CODE_SUCCESSED;
    }
    return lRet;             
}

/**
  * @brief  TemplateClose
  * @note   xxx
  * @param  None
  * @retval None
  */
static long TemplateClose (void *pvHandle)
{
    PST_DEV_MANAGE pstDevManage = pvHandle;
    long lRet = EN_DEV_CTL_RET_CODE_FAILED;
    if (0 != pstDevManage)
    {
        lRet = EN_DEV_CTL_RET_CODE_SUCCESSED;
    }
    return lRet;     
}



/**
  * @brief  g_stTemplateCtlFUN
  * @note  xxx
  * @param  None
  * @retval None
  */
ST_CTR_FUN g_stTemplateCtlFUN = 
{
    TemplateOpen,		//打开
    TemplateRead,		//读
    TemplateWrite,		//写
    TemplateControl,	//控制
    TemplateClose    	//关闭
};


/******************* (C) COPYRIGHT 2011 ShenZhenShiding electronics **************************/
